% Create a serial port object.
obj1 = instrfind('Type', 'serial', 'Port', 'COM29', 'Tag', '');

% Create the serial port object if it does not exist
% otherwise use the object that was found.
if isempty(obj1)
    obj1 = serial('COM29');
else
    fclose(obj1);
    obj1 = obj1(1)
end

% Configure instrument object, obj1.
set(obj1, 'BaudRate', 115200);

% Connect to instrument object, obj1.
fopen(obj1);

flushinput(obj1);

fprintf(obj1, 'A');
data = fread(obj1, 256, 'uint16');
fprintf(obj1, 'B');

plot(data);

fclose(obj1);